package com.example.esp8266.Library.RoomLib;

import android.graphics.Rect;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

/**
 * VerticalSpaceItemDecoration 为 RecyclerView 项目之间添加垂直间隔。
 */
public class VerticalSpaceItemDecoration extends RecyclerView.ItemDecoration {

    private final int verticalSpaceHeight; // 垂直间隔高度

    /**
     * 构造函数
     * @param verticalSpaceHeight 垂直间隔高度（像素）
     */
    public VerticalSpaceItemDecoration(int verticalSpaceHeight) {
        this.verticalSpaceHeight = verticalSpaceHeight;
    }

    @Override
    public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        outRect.bottom = verticalSpaceHeight; // 设置底部间隔
    }
}